// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

@use 'utils/mixins';

.login-body {
    display: flex;
    flex-direction: column;
    padding-bottom: 32px;
    margin: auto;

    .login-body-action {
        display: flex;
        flex-direction: column;
        align-items: flex-end;

        @media (max-width: 700px) {
            width: 100%;
        }
    }

    .login-body-alternate-link {
        margin-bottom: 18px;
    }

    .login-body-content {
        display: flex;
        height: fit-content;
        flex: 1;
        align-items: center;
        justify-content: center;

        .login-body-message-subtitle {
            color: rgba(var(--center-channel-color-rgb), 0.75);
            font-size: 18px;
            font-weight: 400;
            line-height: 28px;
        }

        .login-body-message {
            display: flex;
            width: 540px;
            flex-flow: column;
            align-self: flex-start;

            .login-body-message-title {
                padding-right: 24px;
                color: var(--title-color-indigo-500);
                font-family: Metropolis;
                font-size: 80px;
                font-weight: 600;
                letter-spacing: -0.01em;
                line-height: 88px;
            }

            .login-body-message-svg {
                position: relative;
                align-self: flex-end;

                svg {
                    position: absolute;
                    z-index: 2;
                    bottom: -210px;
                    left: -178px;
                    display: block;
                }
            }

            &.custom-branding {
                padding: 0;

                &.with-brand-image {
                    align-self: center;

                    .login-body-message-subtitle,
                    .login-body-custom-branding-markdown {
                        text-align: left;
                    }
                }

                .login-body-custom-branding-image {
                    max-height: 240px;
                    align-self: self-start;
                    border-radius: 8px;
                    margin-bottom: 28px;
                }
            }

            &.with-alternate-link {
                margin-top: 40px;
            }
        }

        .login-body-card {
            width: 540px;
            box-sizing: border-box;
            border: 1px solid rgba(var(--center-channel-color-rgb), 0.08);
            border-radius: 8px;
            margin-left: 60px;
            background-color: var(--center-channel-bg);
            box-shadow: var(--elevation-5);

            &.with-error {
                @include mixins.shake-horizontally;
            }

            .login-body-card-content {
                display: flex;
                flex: 1;
                flex-flow: column;
                padding: 48px 56px;
                border: none;
                box-shadow: none;

                .login-body-card-title {
                    color: var(--center-channel-color);
                    font-family: 'Metropolis';
                    font-size: 22px;
                    font-style: normal;
                    font-weight: 600;
                    line-height: 28px;
                }

                .login-body-custom-branding-markdown,
                .login-body-message-subtitle {
                    display: none;
                }

                .login-body-card-banner {
                    margin: 20px 0 10px;
                }

                .login-body-card-form {
                    .login-body-card-form-input {
                        margin-top: 22px;
                    }

                    .login-body-card-form-password-input {
                        margin-top: 24px;
                    }

                    .login-body-card-form-link {
                        display: inline-flex;
                        margin-top: 17px;

                        a {
                            @include mixins.link;
                        }
                    }

                    .login-body-card-form-button-submit {
                        @include mixins.primary-button;
                        @include mixins.button-large;

                        width: 100%;
                        margin-top: 30px;
                    }
                }

                .login-body-card-form-divider {
                    display: flex;
                    height: 1px;
                    justify-content: center;
                    margin: 40px 0;
                    background: rgba(var(--center-channel-color-rgb), 0.08);
                    text-align: center;

                    .login-body-card-form-divider-label {
                        padding: 0 10px;
                        background-color: var(--center-channel-bg);
                        color: rgba(var(--center-channel-color-rgb), 0.75);
                        font-size: 12px;
                        line-height: 0;
                    }
                }

                .login-body-card-form-login-options {
                    display: flex;
                    flex: 1;
                    flex-wrap: wrap;
                    justify-content: space-between;
                    column-gap: 8px;
                    row-gap: 8px;

                    &.column {
                        flex-direction: column;
                        margin-top: 22px;
                        row-gap: 24px;
                    }
                }
            }
        }

        .login-body-custom-branding-markdown {
            flex: 1;

            ul + p,
            ol + p {
                margin-top: 0.6em;
            }

            p + ul,
            p + ol {
                margin-top: 0.6em;
            }

            img {
                max-width: 450px;
            }

            p {
                width: 100%;
                margin: 0;
                color: rgba(var(--center-channel-color-rgb), 0.75);
                font-size: 18px;
                font-weight: 400;
                line-height: 28px;
                white-space: pre-wrap;
                word-break: break-word;
            }
        }
    }
}

@media screen and (min-width: 1680px) {
    .login-body .login-body-content {
        .login-body-message,
        .login-body-card {
            width: 610px;
        }

        .login-body-message .login-body-message-title {
            padding-right: 80px;
            margin-top: 48px;
        }
    }
}

@media screen and (max-width: 1199px) {
    .login-body {
        .login-body-alternate-link {
            padding-right: 24px;
        }

        .login-body-content {
            flex-direction: column;

            .login-body-message,
            .login-body-card {
                width: 640px;
            }

            .login-body-message {
                align-self: center;
                padding: 24px;

                .login-body-message-title {
                    padding-right: 80px;
                    font-size: 64px;
                    line-height: 76px;
                }

                .login-body-message-subtitle {
                    margin: 0;
                }

                .login-body-message-svg {
                    display: none;
                }

                &.custom-branding {
                    display: none;
                }
            }

            .login-body-card {
                border: none;
                margin: 0;
                background-color: unset;
                box-shadow: none;

                .login-body-card-content {
                    padding: 16px 24px;

                    .login-body-card-title {
                        display: none;
                    }

                    .login-body-card-banner {
                        margin: 0 0 32px;
                    }

                    .login-body-card-form {
                        .login-body-card-form-input {
                            margin-top: 0;
                        }

                        .login-body-card-form-input,
                        .login-body-card-form-password-input {
                            background-color: var(--center-channel-bg);
                        }
                    }
                }

                &.custom-branding {
                    .login-body-card-content {
                        .login-body-card-title {
                            display: block;
                            margin-bottom: 24px;
                            font-size: 32px;
                            line-height: 40px;

                            &:has(+ .login-body-custom-branding-markdown){
                                margin-bottom: 12px;
                            }
                        }

                        .login-body-custom-branding-markdown,
                        .login-body-message-subtitle {
                            display: block;
                            margin: 0 0 32px;
                            text-align: left;
                        }
                    }
                }
            }
        }
    }
}

@media screen and (max-width: 699px) {
    .login-body {
        margin: auto 0;

        .login-body-content {
            min-width: 375px;

            .login-body-card {
                width: 100%;
            }

            .login-body-message {
                width: auto;
                align-self: flex-start;
                padding: 24px;

                .login-body-message-title {
                    padding-right: 0;
                    font-size: 45px;
                    line-height: 56px;
                }
            }
        }
    }
}
